using UnityEngine;
using UnityEngine.UI;

public class GameGuide : MonoBehaviour
{
    public GameObject guidePanelObject; // 引导面板对象
    public Text guideTextComponent; // 引导文本组件
    public Button nextButton; // 下一步按钮

    private int currentStep = 0; // 当前引导步骤

    private void Start()
    {
        // 初始化引导系统
        guidePanelObject.SetActive(false);
        nextButton.onClick.AddListener(NextStep);
    }

    public void StartGuide()
    {
        // 开始游戏引导
        currentStep = 0;
        guidePanelObject.SetActive(true);
        UpdateGuideText();
    }

    private void NextStep()
    {
        // 切换到下一个引导步骤
        currentStep++;
        UpdateGuideText();

        if (currentStep >= GetTotalSteps())
        {
            // 引导结束,关闭引导面板
            guidePanelObject.SetActive(false);
        }
    }

    private void UpdateGuideText()
    {
        // 根据当前引导步骤更新引导文本
        guideTextComponent.text = GetGuideTextForStep(currentStep);
    }

    private int GetTotalSteps()
    {
        // 返回总引导步骤数
        return 4;
    }

    private string GetGuideTextForStep(int step)
    {
        // 根据引导步骤返回对应的引导文本
        switch (step)
        {
            case 0:
                return "Welcome to the game! Let's start with the basics.";
            case 1:
                return "Use the WASD keys to move your character.";
            case 2:
                return "Press the Spacebar to jump.";
            case 3:
                return "Collect all the coins to complete the level.";
            default:
                return "You've completed the game guide.";
        }
    }
}
